package com.mall.system.controller;

import com.mall.common.domain.MallUser;
import com.mall.common.result.Result;
import com.mall.system.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author wangy
 * @version 1.0
 * @description: TODO
 */
@RestController
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 通过手机号查找用户信息
     *
     * @param phone 参数
     * @return Result<MallUser>
     */
    @GetMapping("findUserByPhone/{phone}")
    public Result<MallUser> findUserByPhone(@PathVariable String phone) {
        MallUser userByPhone = userService.findUserByPhone(phone);
        return Result.success(userByPhone);
    }
    /**
     * 通过id查找用户信息
     *
     * @param id 参数
     * @return Result<MallUser>
     */
    @GetMapping("findUserById/{id}")
    public Result<MallUser> findUserById(@PathVariable Integer id) {
        MallUser userByPhone = userService.findUserById(id);
        return Result.success(userByPhone);
    }
}
